<?php
$sql="select * from slideshow order by id desc limit 0,3";
$slideshow_rows=selectAll($sql);

$sql="select * from other";
$other_row=selectOne($sql);

$sql="select * from news_cate";
$cate_rows=selectAll($sql);
$cate_id=isset($_GET['cate_id'])?$_GET['cate_id']:$cate_rows[0]['id']; 
$sql="select * from news_cate where id=$cate_id";
$cate_row=selectOne($sql);
 
    $p=isset($_GET['p'])?$_GET['p']:1;
	$pagesize=4;
	$index=($p-1)*$pagesize;
	$sql="select * from news where cateid=$cate_id order by id desc limit $index,$pagesize";
    $news_cate=selectAll($sql);
    if(!$news_cate){
       show("该分类无内容！",'index.php?m=home&c=news&#news');
     }

	$sql="select count(id) from news where cateid=$cate_id";
	$row=selectOne($sql);
    $count=$row[0];
    $pages=ceil($count/$pagesize);
    $prepage = $p-1;
    $nextpage = $p+1;
    $str="<ul>";
    if($p>1){
    	$str.="<li ><a href='index.php?m=home&c=news&p=$prepage&#news'>上一页</a></li>";
    }else{
    	$str.="<li ><a href='javascript:;'>上一页</a></li>";
    }
    for($i=$p-2;$i<=$p-1;$i++){
    	if($i>0){
    		$str.="<li><a href='index.php?m=home&c=news&p=$i&#news'>$i</a></li>";
    	}
    }
    $str.="<li><a href='javascript:void(0)' class='on'>$p</a></li>";
    for($i=$p+1;$i<=$p+2;$i++){
    	if($i<$pages){
    		$str.="<li><a href='index.php?m=home&c=news&p=$i&#news'>$i</a></li>";
    	}
    }
    if($p<$pages){
    	$str.="<li ><a href='index.php?m=home&c=news&p=$nextpage&#news'>下一页</a></li>";
    }else{
    	$str.="<li ><a href='javascript:;'>下一页</a></li>";
    }
    $str.="</ul>";




include './html/home/news.html';

?>